"use strict";
cc._RF.push(module, '7718eZi1ndFT62S91GZqVkQ', 'Ipha_SimpleAni_icon');
// scripts/O1ModuleRes/control/Ipha_SimpleAni_icon.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var ANI_TYPE;
(function (ANI_TYPE) {
    ANI_TYPE[ANI_TYPE["NULL"] = 0] = "NULL";
    /** 轻微左右震动 */
    ANI_TYPE[ANI_TYPE["SLIGHT_WAGGLE"] = 1] = "SLIGHT_WAGGLE";
    /** 呼吸缩放 */
    ANI_TYPE[ANI_TYPE["SCALE"] = 2] = "SCALE";
})(ANI_TYPE || (ANI_TYPE = {}));
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, menu = _a.menu;
var Ipha_SlimpleAniIcon = /** @class */ (function (_super) {
    __extends(Ipha_SlimpleAniIcon, _super);
    function Ipha_SlimpleAniIcon() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.aniType = ANI_TYPE.NULL;
        _this.isAutoStart = true;
        _this.isLoop = true;
        _this._scaleDelay = 1;
        _this._scaleSpeed = 0.3;
        _this._xScaleMax = 0.1;
        _this._xScaleMin = 0.1;
        _this._yScaleMax = 0.1;
        _this._yScaleMin = 0.1;
        _this.repeatCnt = 0;
        _this.tag = 1001;
        return _this;
    }
    Ipha_SlimpleAniIcon.prototype.start = function () {
        if (this.isAutoStart) {
            this.playAni();
        }
    };
    Ipha_SlimpleAniIcon.prototype.playAni = function () {
        this.aniType != ANI_TYPE.NULL && this.aniList()[this.aniType]();
    };
    Ipha_SlimpleAniIcon.prototype.aniList = function () {
        var aL = [
            null,
            this.slightWaggle.bind(this),
            this.scale.bind(this),
        ];
        return aL;
    };
    Ipha_SlimpleAniIcon.prototype.slightWaggle = function () {
        if (this.isLoop) {
            cc.tween(this.node).tag(this.tag).sequence(cc.tween().to(0.1, { angle: 5 }).to(0.1, { angle: -5 }), cc.tween().to(0.1, { angle: 5 }).to(0.1, { angle: -5 })).repeatForever().start();
        }
        else {
            this.repeatCnt = this.repeatCnt ? this.repeatCnt : 1;
            cc.tween(this.node).tag(this.tag).sequence(cc.tween().to(0.1, { angle: 5 }).to(0.1, { angle: -5 }), cc.tween().to(0.1, { angle: 5 }).to(0.1, { angle: -5 })).repeat(this.repeatCnt).start();
        }
    };
    Ipha_SlimpleAniIcon.prototype.scale = function () {
        var nodeScaleX = this.node.scaleX;
        var nodeScaleY = this.node.scaleY;
        if (this.isLoop) {
            cc.tween(this.node).sequence(cc.tween().to(this._scaleSpeed, { scaleX: nodeScaleX + this._xScaleMax, scaleY: nodeScaleY + this._yScaleMax }), cc.tween().to(this._scaleSpeed, { scaleX: nodeScaleX - this._xScaleMin, scaleY: nodeScaleY - this._yScaleMin }).delay(this._scaleDelay)).repeatForever().start();
        }
        else {
            cc.tween(this.node).sequence(cc.tween().to(this._scaleSpeed, { scaleX: nodeScaleX + this._xScaleMax, scaleY: nodeScaleY + this._yScaleMax }), cc.tween().to(this._scaleSpeed, { scaleX: nodeScaleX - this._xScaleMin, scaleY: nodeScaleY - this._yScaleMin })).repeat(this.repeatCnt).start();
        }
    };
    Ipha_SlimpleAniIcon.prototype.stopAni = function () {
        this.node.stopActionByTag(this.tag);
    };
    __decorate([
        property({
            type: cc.Enum(ANI_TYPE),
            displayName: "动画类型",
            tooltip: "\u7A7A\n        \u8F7B\u5FAE\u5DE6\u53F3\u6643\u52A8\n        \u547C\u5438\u7F29\u653E",
        })
    ], Ipha_SlimpleAniIcon.prototype, "aniType", void 0);
    __decorate([
        property({ displayName: "自动开始" })
    ], Ipha_SlimpleAniIcon.prototype, "isAutoStart", void 0);
    __decorate([
        property({
            displayName: "是否循环播放",
            visible: function () {
                return this.aniType == ANI_TYPE.SLIGHT_WAGGLE
                    || this.aniType == ANI_TYPE.SCALE;
            }
        })
    ], Ipha_SlimpleAniIcon.prototype, "isLoop", void 0);
    __decorate([
        property({
            displayName: "呼吸缩放 延迟",
            visible: function () {
                return this.aniType == ANI_TYPE.SCALE;
            }
        })
    ], Ipha_SlimpleAniIcon.prototype, "_scaleDelay", void 0);
    __decorate([
        property({
            displayName: "呼吸缩放 速度",
            visible: function () {
                return this.aniType == ANI_TYPE.SCALE;
            }
        })
    ], Ipha_SlimpleAniIcon.prototype, "_scaleSpeed", void 0);
    __decorate([
        property({
            displayName: "横轴缩放MAX",
            visible: function () {
                return this.aniType == ANI_TYPE.SCALE;
            }
        })
    ], Ipha_SlimpleAniIcon.prototype, "_xScaleMax", void 0);
    __decorate([
        property({
            displayName: "横轴缩放MIN",
            visible: function () {
                return this.aniType == ANI_TYPE.SCALE;
            }
        })
    ], Ipha_SlimpleAniIcon.prototype, "_xScaleMin", void 0);
    __decorate([
        property({
            displayName: "竖轴缩放MAX",
            visible: function () {
                return this.aniType == ANI_TYPE.SCALE;
            }
        })
    ], Ipha_SlimpleAniIcon.prototype, "_yScaleMax", void 0);
    __decorate([
        property({
            displayName: "竖轴缩放MIN",
            visible: function () {
                return this.aniType == ANI_TYPE.SCALE;
            }
        })
    ], Ipha_SlimpleAniIcon.prototype, "_yScaleMin", void 0);
    __decorate([
        property({
            displayName: "循环次数",
            visible: function () {
                return !this.isLoop;
            }
        })
    ], Ipha_SlimpleAniIcon.prototype, "repeatCnt", void 0);
    Ipha_SlimpleAniIcon = __decorate([
        ccclass,
        menu("ipha/slimpleAni_icon")
    ], Ipha_SlimpleAniIcon);
    return Ipha_SlimpleAniIcon;
}(cc.Component));
exports.default = Ipha_SlimpleAniIcon;

cc._RF.pop();